<template>
  <div class="error-page">
    <p>
      <span v-for="(item, index) in errorTexts" :key="index">{{ item }}</span>
    </p>
    <p class="error-page__desc">{{ desc }}(´･ω･`)</p>
    <Button class="error-page__btn" type="primary" @click="backTo">返回首页</Button>
  </div>
</template>

<script>
export default {
  computed: {
    errorTexts() {
      const code = +this.$route.params.code;
      return code.toString().split("");
    },

    desc() {
      const code = +this.$route.params.code;
      if (code === 403) {
        return "您暂时没有操作权限，请联系管理员";
      } else if (code === 404) {
        return "页面未找到，请联系管理员";
      } else if (code === 500) {
        return "页面出错了，请联系管理员";
      } else if (code === 401) {
        return "登录过期了，请重新登录";
      }
    }
  },

  methods: {
    backTo() {
      this.$router.replace({ path: '/' });
    }
  }
};
</script>

<style lang="scss">
.error-page {
  width: 600px;
  margin: 100px auto;
}
.error-page p:first-child {
  text-align: center;
  font-family: cursive;
  font-size: 150px;
  font-weight: bold;
  line-height: 100px;
  letter-spacing: 5px;
  color: #fff;
}

.error-page p:first-child span {
  cursor: pointer;
  text-shadow: 0px 0px 2px #686868, 0px 1px 1px #ddd, 0px 2px 1px #d6d6d6,
    0px 3px 1px #ccc, 0px 4px 1px #c5c5c5, 0px 5px 1px #c1c1c1, 0px 6px 1px #bbb,
    0px 7px 1px #777, 0px 8px 3px rgba(100, 100, 100, 0.4),
    0px 9px 5px rgba(100, 100, 100, 0.1), 0px 10px 7px rgba(100, 100, 100, 0.15),
    0px 11px 9px rgba(100, 100, 100, 0.2),
    0px 12px 11px rgba(100, 100, 100, 0.25),
    0px 13px 15px rgba(100, 100, 100, 0.3);
  -webkit-transition: all 0.1s linear;
  transition: all 0.1s linear;
}

.error-page p:first-child span:hover {
  text-shadow: 0px 0px 2px #686868, 0px 1px 1px #fff, 0px 2px 1px #fff,
    0px 3px 1px #fff, 0px 4px 1px #fff, 0px 5px 1px #fff, 0px 6px 1px #fff,
    0px 7px 1px #777, 0px 8px 3px #fff, 0px 9px 5px #fff, 0px 10px 7px #fff,
    0px 11px 9px #fff, 0px 12px 11px #fff, 0px 13px 15px #fff;
  -webkit-transition: all 0.1s linear;
  transition: all 0.1s linear;
}

.error-page__desc {
  text-align: center;
  color: #666;
  font-size: 20px;
  text-shadow: 0 1px 0 #fff;
  letter-spacing: 1px;
  line-height: 2em;
  margin-top: 30px;
}

.error-page__btn {
  display: block;
  width: 120px;
  margin: 20px auto;
}
</style>
